<template>
  <div class="wrap" v-if="tabsList.length">
    <a-tabs default-active-key="1" tabPosition="left">
      <a-tab-pane :key="item.id" :tab="item.name" v-for="item in tabsList">
        <div class="wrap_button" v-if="item.typeSecond in $store.state.formJson.formObj[type]">
          <div class="wrap_button_left">
            <span>自动回显：</span>
            <a-switch
              v-model="$store.state.formJson.formObj[type][item.typeSecond].auto"
              checked-children="开"
              un-checked-children="关"
            />
          </div>
          <a-popconfirm title="确认重置该项配置？" ok-text="确认" cancel-text="取消" @confirm="reset(item.typeSecond)">
            <a-button type="danger">重置</a-button>
          </a-popconfirm>
        </div>
        <BasePaneItem :type="type" :typeSecond="item.typeSecond"></BasePaneItem>
      </a-tab-pane>
    </a-tabs>
  </div>
</template>

<script>
import { dropKey } from '@/views/businessAssembly/jsonComponent/constant/dropKey.js'

export default {
  props: {
    type: {
      type: String,
      default: ''
    }, // 一级分类
    tabsList: {
      type: Array,
      default: () => {
        return []
      }
    } // 标签列表
  },
  data() {
    return {}
  },
  components: {
    BasePaneItem: () => import('@/views/businessAssembly/jsonComponent/basePaneItem.vue')
  },
  mounted() {},
  methods: {
    // 组件初始化
    async init() {},
    // 重置数据
    reset(typeSecond) {
      if (this.type == 'DROP') {
        let arry = []
        for (let key in dropKey[typeSecond]) {
          let tempObj = {}
          tempObj = { b: key, mapping: '', describe: dropKey[typeSecond][key] }
          if (key == 'adid') {
            tempObj.isparam = true
          } else if (key == 'preacceptsectionid' || key == 'e_lng' || key == 'e_lat') {
            tempObj.isparam = false
          }
          arry.push(tempObj)
        }
        this.$store.state.formJson.formObj[this.type][typeSecond] = {
          attrForm: {
            title: '',
            type: 'single',
            ismultiple: 'false',
            filter: {},
            fiterList: []
          },
          filedList: arry,
          auto: false
        }
      } else {
        this.$store.state.formJson.formObj[this.type][typeSecond] = {
          attrForm: {
            apltable: '',
            title: '',
            table: '',
            yjctable: '',
            type: 'single',
            autoacho: 'true',
            emptybtn: 'false',
            params: {},
            paramsList: [],
            filter: {},
            fiterList: []
          },
          filedList: [],
          auto: false
        }
      }
    }
  }
}
</script>

<style scoped>
.wrap_button {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.wrap_button_left {
  display: flex;
  align-items: center;
}
</style>
